package com.xy.shop.system.config;

import com.xy.shop.common.constant.WebConstants;
import com.xy.shop.common.utils.WebUtil;
import com.xy.shop.system.entity.User;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

/**
 * @Description
 * @Author jxp
 **/
//@ControllerAdvice
public class MyControllerAdvice {

   /* @Autowired
    private WebUtil webUtil;

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Value("${system.name}")
    private String systemName;

    @ModelAttribute(name="systemName")
    public String title() {
        User user = (com.xy.shop.system.entity.User) SecurityUtils.getSubject().getPrincipal();
        if (user != null) {
            String appInfo = redisTemplate.opsForValue().get(WebConstants.RedisKeyPrefix.APPID+user.getLoginName());
            if(StringUtils.isNotBlank(appInfo)){
                String appName = webUtil.getAppName(user.getLoginName());
                if(StringUtils.isNotBlank(appName)){
                    return appName;
                }
            }
        }
        return systemName;
    }*/
}
